package com.code.thread.deadlock;

/**
 * 哲学家就餐问题
 */
public class PhilosopherDemo {

    public static void main(String[] args) {
        ChopStick cs1 = new ChopStick();
        ChopStick cs2 = new ChopStick();
        ChopStick cs3 = new ChopStick();
        ChopStick cs4 = new ChopStick();
        ChopStick cs5 = new ChopStick();

        Philosopher p1 = new Philosopher("P1", 0, cs1, cs2);
        Philosopher p2 = new Philosopher("P2", 1, cs2, cs3);
        Philosopher p3 = new Philosopher("P3", 2, cs3, cs4);
        Philosopher p4 = new Philosopher("P4", 3, cs4, cs5);
        Philosopher p5 = new Philosopher("P5", 4, cs5, cs1);
        p1.start();
        p2.start();
        p3.start();
        p4.start();
        p5.start();
    }
}
